﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TSVNAddin.Config
{
	public class ConfigStorage
	{
		private readonly XmlFileStorage _XmlFileStorage;

		public ConfigStorage(XmlFileStorage xmlFileStorage)
		{
			_XmlFileStorage = xmlFileStorage;
		}

		public virtual AddinConfig LoadAddinConfig()
		{
			return _XmlFileStorage.ReadObjectFromFile<AddinConfig>(GetFileName());
		}

		public virtual void StoreAddinConfig(AddinConfig config)
		{
			_XmlFileStorage.WirteObjectToFile(config, GetFileName());
		}

		private string GetFileName()
		{
			return Environment.GetEnvironmentVariable("ALLUSERSPROFILE") + @"\TortoiseSVNAddin\AddinConfig.xml";
		}
	}
}
